package cn.ycc1.baseset.basics;

/**
 * 表达式
 * Expressions, Statements and Blocks
 * @author ycc
 * @date 2025/3/3
 */
public class Expressions {
    /**
     * Floating Point Arithmetic
     */
    public static void floating() {
        double d1 = 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1;
        System.out.println("d1 == 1 ? " + (d1 == 1.0));
    }

    /**
     * Statements
     */
    public static void statements() {
        // declaration statement
        double aValue = 8933.234;

        // assignment statement
        aValue = 8933.234;

        // increment statement
        aValue++;

        // method invocation statement
        System.out.println("Hello World!");

        // object creation statement
        // Bicycle myBike = new Bicycle();

    }

    /**
     * Blocks
     */
    public static void blocksDemo() {
        boolean condition = true;
        if (condition) { // begin block 1
            System.out.println("Condition is true.");
        } // end block one
        else { // begin block 2
            System.out.println("Condition is false.");
        } // end block 2
    }

    /**
     * Expressions
     * An expression is a construct made up of variables, operators, and method invocations,
     * which are constructed according to the syntax of the language, that evaluates to a single value.
     * You have already seen examples of expressions, illustrated in code below:
     * @param args
     */
    public static void main(String[] args) {
//        int cadence = 0;
//        anArray[0] = 100;
//        System.out.println("Element 1 at index 0: " + anArray[0]);
//
//        int result = 1 + 2; // result is now 3
//        if (value1 == value2)
//            System.out.println("value1 == value2");
        floating();

    }
}
